<?php

Raise::load('core.helper.config.RaiseSettings');

/**
 * TestCoreRaiseSettings
 * Testing unit of 'phpraise/core/RaiseSettings.php'
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestCoreRaiseSettings extends RaiseTest {

    public static function testSettings(){

        self::assertClassExists('RaiseSettings');
        self::assertClassExtends('RaiseSettings', 'RaiseHelper');

        $settings = new RaiseSettings('mocks/MockConfigFile.ini');

        self::assertObjectClass($settings, 'RaiseSettings');
        self::assertStrictEqual($settings->get('phpRaise', 'appName'), 'phpRaise Development');
        self::assertStrictEqual($settings->get('Database', 'default'), 'mysql:host=localhost;dbname=RaiseMockDb;user=root;pwd=password');
        self::assertStrictEqual($settings->get('phpRaise', 'timezone'), 'GMT');

    }

    public static function testBadFileSettings(){

        if(RaiseFileSystem::fileExist('mocks/BadFile.ini')){
            RaiseFileSystem::deleteFile('mocks/BadFile.ini');
        }

        try{
            $settings = new RaiseSettings('mocks/BadFile.ini');
            self::assert(false);
        }catch(Exception $e){
            self::assertObjectClass($e, 'RaiseFileOperationFailedException');
        }
    }

}

